package com.yehongyu.mytools.basic.grammar;

public class Java004_Constructor extends Java004_ConstructorParent {

	public Java004_Constructor() {
		System.out.println("child constructor without parameters");
	}

	public Java004_Constructor(int type) {
		System.out.println("child constructor with parameters[" + type + "]");
	}

	public static void main(String[] args) {
		// 测试构造函数，先初始化父类（默认构造函数），再初始化子类（指定的构造函数）
		new Java004_Constructor(1);
	}
}

class Java004_ConstructorParent {

	public Java004_ConstructorParent() {
		System.out.println("parent constructor without parameters");
	}

	public Java004_ConstructorParent(int type) {
		System.out.println("parent constructor with parameters[" + type + "]");
	}
}
